// testDataInterface.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "sqlite3.h"
#include <stdlib.h>
#include "DataBaseWrapper.h"
#pragma comment(lib,"../sqlite3.lib")

using namespace grid;
using namespace std;
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
  int i;
  for(i=0; i<argc; i++){
    printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  }
  printf("\n");
  return 0;
}

int _tmain(int argc, _TCHAR* argv[]){


	DataBaseWrapper dbw;
	wstring dbname = L"test.db";
	dbw.openDatabase(dbname);
	SqlResult result;
	wstring error;
	dbw.exec(wstring(L"create table tbl1(one varchar(10), two smallint)"), result, error); 
    dbw.exec(wstring(L"insert into tbl1 values('hello!',10)"), result, error);
	dbw.exec(wstring(L"insert into tbl1 values('goodbye', 20)"), result, error);
	dbw.exec(wstring(L"select * from tbl1"), result, error);


 /* 
  sqlite3 *db;
  char *zErrMsg = 0;
  int rc;
  if( argc!=3 ){
    fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
    exit(1);
  }
  rc = sqlite3_open(argv[1], &db);
  if( rc ){
    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    exit(1);
  }
  rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
  if( rc!=SQLITE_OK ){
    fprintf(stderr, "SQL error: %s\n", zErrMsg);
    sqlite3_free(zErrMsg);
  }
  sqlite3_close(db);*/
  return 0;
}


